
************************************************************;
** Impute RTI Race variable from 2009 data to 2008 data    *;
************************************************************;

options ls=76 nofmterr;

libname raw '/data/Medicare_P01_2009/data/HEDIS/rawdata';
libname new '/data/Medicare_P01_2009/data/HEDIS/sasdata';


data id08; set raw.linkid2008;
     proc sort; by id_num;

data id09; set raw.linkid2009;
     proc sort; by id_num;

data a08; set new.hedis2008;

     proc sort; by id_num;

data h08; merge a08(in=ok) id08; by id_num;

     if ok;

     proc sort; by hic_number;

data a09; set new.hedis2009;

     keep rti_race_cd id_num;
     proc sort; by id_num;

data h09; merge a09 id09; by id_num;

     proc sort; by hic_number;

data new.hedis2008; merge h08(in=ok) h09; by hic_number;  

     if ok;

     length rti_racec $ 10;

          if rti_race_cd = '1' then rti_racec='1.White';
     else if rti_race_cd = '2' then rti_racec='2.Black';
     else if rti_race_cd = '5' then rti_racec='3.Hispanic';
     else if rti_race_cd = '4' then rti_racec='4.Asian';
     else if rti_race_cd in ('3','6','0') then rti_racec='5.Other';

     if denom_flag=0 then rti_racec=' ' ;

     proc freq data=new.hedis2008(where=(denom_flag=1));
          tables rti_racec racec/missing;

endsas;
